<?php 
class keysAction extends AdminMaster{
	public function showList(){
		$this->data['list']			 		= ProductKeys::getDataList($this->data['filter'], $this->data['pagination']);
		$this->data['pagination']['total']		= ProductKeys::getDataListCount($this->data['filter']);
		$this->data['pagination']['router']		= 'products_key';
		$this->data['pagination']['params']		= $this->data['filter'];
	}
	public function delRecord(){
		ProductKeysTable::delete($this->data['select_list']);
	}
	public function disableRecord(){
		ProductKeysTable::disable($this->data['select_list']);
	}
	public function enableRecord(){
		ProductKeysTable::enable($this->data['select_list']);
	}
	
	public function addnew(){
		$this->setTemplate('keysForm');

		$form = new ProductKeysFForm();
		if($this->data['is_post']){
			$form->bind($this->formData);
			
			if($form->isValid()){ 
				$product_id = ProductKeys::insertUpdate($this->formData);
				if($product_id > 0){
					$this->data['result']	= __('add_new_success');
					$form = new ProductKeysFForm();
				}else{
					$this->data['result']	= sprintf(__('add_new_error'), sfConfig::get('app_email_admin')) ;
				}
			}else{
				foreach($form->getErrorSchema()->getErrors() as $f){
					print_r($f->__toString());
				}
				die;
			}
		}
		$this->setVar('form', $form);
	}
}